import basic from '../../../xc/model/basic.js';
var actmodel = new basic();
actmodel.do = "club_barter"
actmodel.getclubid=function(){
  var actleadgroup =getApp().globalData.actleadgroup
  return actleadgroup.id;
}
actmodel.applyform = function (formdata) {
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/' + actmodel.do,
      'data': {
        "op": "applyform",
        clubid:actmodel.getclubid(), 
        formdata:JSON.stringify(formdata)
      },
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}

actmodel.orderinfo = function (ordernum) {
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/' + actmodel.do,
      'data': {
        "op": "orderinfo",
        ordernum:ordernum,
        clubid:actmodel.getclubid() 
      },
      'method': "get",
      showLoading: false,
      success: function (res) {
        if (res.data.errno == 0) {
          resolve(res.data.data);
        }
        reject(res.data.message);
      },
      fail: function (res) {
        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}

actmodel.offset = function (that, reset, para, xcsorts) { 
  if(!xcsorts)
  {
    xcsorts=[["id", "desc"], ["modifytime", "desc"]] ;
  } 
  var acturlpara = {};   
  acturlpara["url"] = "entry/wxapp/"+actmodel.do
  if (para) {
    para["op"] = "offset"
  }
  else
  {
    para={}
  }
  
  para["clubid"]=actmodel.getclubid() 
  return actmodel.pagelist(acturlpara, that, reset, para, xcsorts);
} 


module.exports = actmodel;